﻿using Administratation.Models;
using System.Collections.ObjectModel;
using DAL;
using System.ComponentModel;
using System.Windows.Data;
using System;
namespace Administratation.ViewModels
{
    public class ViewModelOffersBrowser : ViewModelBase
    {
        private OffersBrowserModel model;

        public ViewModelOffersBrowser()
        {
            this.model = new OffersBrowserModel();
            var viewOffers = this.GetDefaultOffersView();
            viewOffers.CurrentChanged += new EventHandler(viewOffers_CurrentChanged);
        }

        void viewOffers_CurrentChanged(object sender, EventArgs e)
        {
            //OnPropertyChanged("SelectedOffer");
        }

        public ObservableCollection<Offer> Offers
        {
            get
            {
                return this.model.Offers;
            }
        }

        private ICollectionView GetDefaultOffersView()
        {
            var view = CollectionViewSource.GetDefaultView(this.Offers);
            return view;
        }

        public Offer SelectedOffer
        {
            get
            {
                return GetDefaultOffersView().CurrentItem as Offer;
            }
        }
    }
}
